//
//  FCLoginViewController.swift
//  FinancialConsulting
//
//  Created by Max on 2017/10/31.
//  Copyright © 2017年 com.vector. All rights reserved.
//

import UIKit

class FCLoginViewController: FCViewController {

    @IBOutlet weak var userName: UITextField!
    @IBOutlet weak var passWord: UITextField!
    @IBOutlet weak var rememberWord: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.rememberWord.setImage(UIImage(named:"26"),for: .normal)
        self.rememberWord.setImage(UIImage(named:"25"),for: .selected)
    }

    @IBAction func loginAction(_ sender: Any) {
    
        if (userName.text?.characters.count)! > 10 {
            if (passWord.text?.characters.count)! > 5 {
                
                let v = FCCenterViewController()
                
                FCModelData.instance.isLogin = true
                FCModelData.instance.userName = userName.text!
                self.navigationController?.pushViewController(v, animated: true)
                
            }else {
                
                let alert = UIAlertController.init(title: "请正确输入手机号和密码", message: nil, preferredStyle: .alert)
                let alertCancelAction: UIAlertAction = UIAlertAction.init(title: "确认", style: UIAlertActionStyle.cancel, handler: nil)
                
                alert.addAction(alertCancelAction)
                self.present(alert, animated: true, completion: nil)
                
                
                
            }
        }else {
            
            let alert = UIAlertController.init(title: "请正确输入手机号和密码", message: nil, preferredStyle: .alert)
            let alertCancelAction: UIAlertAction = UIAlertAction.init(title: "确认", style: UIAlertActionStyle.cancel, handler: nil)
            
            alert.addAction(alertCancelAction)
            self.present(alert, animated: true, completion: nil)
            
            
            
        }
    }
   
    @IBAction func forgotPasswordAction(_ sender: Any) {
    
    }
    
    
    @IBAction func registeredActio(_ sender: Any) {
    
        if let v = FCRegisteredViewController.create() as? FCRegisteredViewController {
        
            self.navigationController?.pushViewController(v, animated: true)
        }
    }
    
    @IBAction func rememberPassword(_ sender: UIButton) {
  
        sender.isSelected = !sender.isSelected

    }
    
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    




}
